<?php 
	
	if ( isset($_POST['modify_contact_page']) && $_POST['modify_contact_page'] == 'true')
	{
		modify_contact_page();
	}
	
	function modify_contact_page()
	{
		update_option('enable_google_maps', $_POST['enable_google_maps'] );
		update_option('google_maps_url', stripslashes($_POST['google_maps_url']) );
		
		update_option('destination_email', stripslashes($_POST['destination_email']) );
		
		update_option('contact_name_required', $_POST['contact_name_required'] );
		update_option('contact_company_required', $_POST['contact_company_required'] );
		update_option('contact_phone_required', $_POST['contact_phone_required'] );

		update_option('use_recaptcha', $_POST['use_recaptcha'] );
		update_option('recaptcha_public_key', stripslashes($_POST['recaptcha_public_key']) );
		update_option('recaptcha_private_key', stripslashes($_POST['recaptcha_private_key']) );
	}
	
	function create_wordpress_admin_contact_page_submenu()
	{
		add_submenu_page( 'my-top-level-handle', 'Contact Page', 'Contact Page', 'manage_options', 'my-submenu-contact-handle', 'contact_admin_page');
		add_action('admin_init', 'register_contact_settings');
	
	}
	
	function register_contact_settings()
	{
		register_setting('contact_page_options', 'enable_google_maps');
		register_setting('contact_page_options', 'google_maps_url');
		
		register_setting('contact_page_options', 'destination_email');
		
		register_setting('contact_page_options', 'contact_name_required');
		register_setting('contact_page_options', 'contact_company_required');
		register_setting('contact_page_options', 'contact_phone_required');
		
		register_setting('contact_page_options', 'use_recaptcha');
		register_setting('contact_page_options', 'recaptcha_public_key');
		register_setting('contact_page_options', 'recaptcha_private_key');
	}
	
	function contact_admin_page() {
		

?>
	<script type="text/javascript" language="javascript">
		/* function for confirming you want to delete */
		function confirmAction()
		{
			return confirm("Are you sure you want to delete this slide?")
		}
		
		jQuery(document).ready(function() {
			jQuery('.header').click(function() {
				jQuery(this).next('.hidden_content').stop(true, true).toggle('fast');
			});
		});
		
		jQuery(document).ready(function() {
			jQuery("#contact_tabs").tabs();
			jQuery(".transform").jqTransform();
		});
	</script> 
    
<div class="wrap">  
    <div id="icon-options-general" class="icon32"><br /></div>
    <h2>Contact Page</h2>  
    
     <?php
	$get_admin_warnings = admin_warnings();
	if ( $get_admin_warnings != '' )
	{
		echo '<div id="admin_warnings">';
			echo '<div id="admin_warning_icon"></div>';
			echo $get_admin_warnings;
		echo '</div>';
	}
	?>
    
<div id="contact_tabs" class="admin_tabs">
    <ul>
        <li>
            <a href="#">
                Settings
            </a>
        </li>
</div>
    
    	<form method="post" action="#tab_add_blog" class="transform">
        	<input type="hidden" name="add_new_blog" value="true" />
        
            <div class="settings_wrapper">
                <div class="header">
                    Contact Page Settings
                </div>
                <div class="row_data">
        
        			<input type="hidden" name="modify_contact_page" value="true" />
                    
                    <div class="row clearfix alternate">
                        <label>Google Maps</label>
                        <select name="enable_google_maps">
							<option value="yes" <?php if ( get_option('enable_google_maps') == 'yes' ) echo ' selected="selected"'; ?>>Yes</option>
                            <option value="no" <?php if ( get_option('enable_google_maps') == 'no' ) echo ' selected="selected"'; ?>>No</option>
                        </select>
                    </div>
                    
                    <div class="row clearfix">
                        <label>Google Maps URL</label>
                        <input type="text" name="google_maps_url" class="input_box" value="<?php echo get_option('google_maps_url'); ?>" />
                    </div>
                    
                    <div class="row clearfix alternate">
                        <label>Destination e-mail</label>
                        <input type="text" name="destination_email" class="input_box" value="<?php echo get_option('destination_email'); ?>" />
                    </div>
                    
                    <div class="row clearfix">
                        <label>Use Recaptcha</label>
                        <select name="use_recaptcha">
							<option value="yes" <?php if ( get_option('use_recaptcha') == 'yes' ) echo ' selected="selected"'; ?>>Yes</option>
                            <option value="no" <?php if ( get_option('use_recaptcha') == 'no' ) echo ' selected="selected"'; ?>>No</option>
                        </select>
                    </div>
                    
                    <div class="row clearfix alternate">
                        <label>Name required?</label>
                        <select name="contact_name_required">
							<option value="yes" <?php if ( get_option('contact_name_required') == 'yes' ) echo ' selected="selected"'; ?>>Yes</option>
                            <option value="no" <?php if ( get_option('contact_name_required') == 'no' ) echo ' selected="selected"'; ?>>No</option>
                        </select>
                    </div>
                    
                    <div class="row clearfix">
                        <label>Company required ?</label>
                        <select name="contact_company_required">
							<option value="yes" <?php if ( get_option('contact_company_required') == 'yes' ) echo ' selected="selected"'; ?>>Yes</option>
                            <option value="no" <?php if ( get_option('contact_company_required') == 'no' ) echo ' selected="selected"'; ?>>No</option>
                        </select>
                    </div>
                    
                    <div class="row clearfix alternate">
                        <label>Phone Number required ?</label>
                        <select name="contact_phone_required">
							<option value="yes" <?php if ( get_option('contact_phone_required') == 'yes' ) echo ' selected="selected"'; ?>>Yes</option>
                            <option value="no" <?php if ( get_option('contact_phone_required') == 'no' ) echo ' selected="selected"'; ?>>No</option>
                        </select>
                    </div>
                    
                    <div class="row clearfix">
                        <label>reCAPTCHA public key</label>
                        <input type="text" name="recaptcha_public_key" class="input_box" value="<?php echo get_option('recaptcha_public_key'); ?>" />
                    </div>
                    
                    <div class="row clearfix alternate">
                        <label>reCAPTCHA private key</label>
                        <input type="text" name="recaptcha_private_key" class="input_box" value="<?php echo get_option('recaptcha_private_key'); ?>" />
                    </div>
                    
                    <div class="row clearfix">
                        <input name="Submit" type="submit" class="save_button" value="<?php esc_attr_e('Save Changes'); ?>" />
                    </div>
                    
                </div>
                
                <div class="footer">
                    Contact Page Settings
                </div>
            </div>
	
		</form>
    
</div> <!-- END  .wrap  -->  

<?php
	} // END blog_admin_page()
?>